<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="/css/admin.css">
    
    <style>
        .el-header, .el-footer {
            background-color: #B3C0D1;
            color: #333;
            text-align: center;
            line-height: 60px;
        }
        
        .el-aside {
            background-color: #D3DCE6;
            color: #333;
            text-align: center;
            line-height: 200px;
        }
        
        .el-main {
            background-color: #E9EEF3;
            color: #333;
            text-align: center;
            line-height: 160px;
        }
        
        body > .el-container {
            margin-bottom: 40px;
        }
        
        .el-container:nth-child(5) .el-aside,
        .el-container:nth-child(6) .el-aside {
            line-height: 260px;
        }
        
        .el-container:nth-child(7) .el-aside {
            line-height: 320px;
        }
    </style>
</head>
<body>
<div id="app">
    <el-col :xs="{span:20,offset:0}" :sm="{span:14,offset:5}" :md="{span:8,offset:7}" :xl="{span:6,offset:8}">
        <br> <br> <br> <br> <br> <br> <br>
        <el-form ref="form" :model="form" label-width="80px" :rules="rules">
            <el-form-item label="用户名" prop="name">
                <el-input v-model="form.name"></el-input>
            </el-form-item>
            <el-form-item label="密码" prop="password">
                <el-input v-model="form.password" type="password"></el-input>
            </el-form-item>
            <!--<el-form-item label="活动区域">-->
            <!--<el-select v-model="form.region" placeholder="请选择活动区域">-->
            <!--<el-option label="区域一" value="shanghai"></el-option>-->
            <!--<el-option label="区域二" value="beijing"></el-option>-->
            <!--</el-select>-->
            <!--</el-form-item>-->
            <el-form-item>
                <el-button type="primary" @click="onSubmit">登录</el-button>
                <el-button>取消</el-button>
            </el-form-item>
        </el-form>
    </el-col>
</div>
</body>
<!-- import Vue before Element -->
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- import JavaScript -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
    new Vue({
        el: '#app',
        data: function () {
            return {
                rules: {
                    name: [
                        {required: true, message: '请输入用户名', trigger: 'blur'},
                        {min: 3, max: 15, message: '长度在 3 到 15 个字符', trigger: 'blur'}
                    ],
                    password: [
                        {required: true, message: '请输入密码', trigger: 'blur'},
                        {min: 3, max: 15, message: '长度在 3 到 15 个字符', trigger: 'blur'}
                    ]
                },
                visible: false,
                filter: {
                    page: 1,
                },
                total: 0,
                form: {
                    name: '',
                    password: '',
                    // region: '',
                    // date1: '',
                    // date2: '',
                    // delivery: false,
                    // attrs: [],
                    // resource: '',
                    // desc: ''
                }
            }
        },
        methods: {
            onSubmit() {
                let self = this;
                this.$refs['form'].validate((valid) => {
                    if (valid) {
                        // passport.login(this.form, this.$route);
                        axios.post('{{route('admin.login')}}', this.form).then(function (response) {
                            if (response.data.status === 0) {
                                location.href = '{{route('admin.order')}}';
                            }

                            self.$message.error(response.data.msg);
                        }.bind(this));
                        // alert('submit!');
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });

            },
        },
        mounted() {

        }
    })
</script>
</html>